package com.example.principle.model;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BeanLifeComponent implements BeanNameAware {
    private Server server;

    @Autowired
    public void setServer(Server server) {
        this.server = server;
        System.out.println("执行属性注入...");
    }

    public BeanLifeComponent() {
        System.out.println("执行构造方法...");
    }

    @PostConstruct
    public void init(){
        System.out.println("执行初始化...");
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("setBeanName...");
    }

    public void process(){
        System.out.println("使用中...");
    }

    @PreDestroy
    public void preDestroy(){
        System.out.println("执行 preDestroy...");
    }
}
